import subprocess
from time import sleep

__author__ = 'Administrator'

import os
import shutil
import sys

tomcatPath = "E:\\apache-tomcat-6.0.43\\"

os.chdir(tomcatPath + "\\bin\\")

subprocess.call([tomcatPath + "\\bin\\startup.bat"])


# subprocess.Popen(args=[], executable=tomcatPath + "\\bin\\startup.bat")


# print(*sys.argv)
# print(os.execv(tomcatPath + "\\bin\\startup.bat", sys.argv))


# os.execlp("D:\\Program Files\\Java\\jdk1.6.0_45\\bin\\java.exe","java")



# os.execlp(tomcatPath + "\\bin\\startup.bat", "startup.bat")


# os.execl(tomcatPath + "\\bin", "startup.bat")


# for line in stream:
#     print(line)


def deleteFileOrFolder(directory):
    if os.path.exists(directory):
        try:
            if os.path.isdir(directory):
                # delete folder
                shutil.rmtree(directory)
            else:
                # delete file
                os.remove(directory)
        except:
            print("exception ", sys.exc_info()[0])
            raise
    else:
        print("not found", directory)
